package com.novel.controller;

import com.novel.annotation.ResponseResult;
import com.novel.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api("文件管理")
@RestController
@ResponseResult
@RequestMapping("/file")
public class FileController {

    @Resource
    private FileService fileService;

    /**
     * 文件上传
     *
     * @param file 文件
     */
    @ApiOperation(value = "文件上传")
    @PostMapping("upload")
    public String upload(@ApiParam(name = "file", value = "文件", required = true) @RequestParam("file") MultipartFile file) {
        //返回r对象
        return fileService.upload(file);
    }
}